package 线程通信;

public class Main {
    public static void main(String[] args) {
        Desk desk = new Desk();

        new Thread(() -> {
            while (true) {
                try {
                    desk.put();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }, "厨师1").start();

        new Thread(() -> {
            while (true) {
                try {
                    desk.put();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }, "厨师2").start();


        new Thread(() -> {
            while (true) {
                try {
                    desk.put();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }, "厨师3").start();

        new Thread(() -> {
            while (true) {
                try {
                    desk.get();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }, "客人1").start();

        new Thread(() -> {
            while (true) {
                try {
                    desk.get();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }, "客人2").start();
    }
}
